#pragma once

#include <string>
#include <map>
#include <variant>
#include <string>
#include <cstdint>
#include <functional>

#include "Structs.h"

#ifdef _WIN32
#ifdef ISCLIBLIDAR_EXPORTS
#define ISCLIBLIDAR_API __declspec(dllexport)
#elif defined(DEMO_BUILD)
#define ISCLIBLIDAR_API  // 在demo模式下不使用导入/导出
#else
#define ISCLIBLIDAR_API __declspec(dllimport)
#endif
#else
#define ISCLIBLIDAR_API
#endif

using ConfValueType = std::variant<float, bool, std::string, uint16_t, LidarInputSourceType, LidarManufacturerType, LidarDecodeType, TransformParam>;
using ParameterChangedNotify = std::function<void(std::string, ConfValueType &)>;

/// @brief 运行配置项
class ISCLIBLIDAR_API LidarConfigurationOptions
{
public:
    LidarConfigurationOptions();
    virtual ~LidarConfigurationOptions();

public:
    static constexpr const char *All = "All";

    // Lidar Driver
    static constexpr const char *Data_Source_SrcType = "Data_Source_SrcType"; // 从Online，Pcap File，Raw Package, PCD file
    static constexpr const char *Data_SrcNet_ManuType = "Data_SrcNet_ManuType";
    static constexpr const char *Data_SrcNet_MsopPort = "Data_SrcNet_MsopPort"; // 从Online
    static constexpr const char *Data_SrcNet_DifopPort = "Data_SrcNet_DifopPort";
    static constexpr const char *Data_SrcNet_RemoteIP = "Data_SrcNet_RemoteIP";
    static constexpr const char *Data_SrcNet_LocalIP = "Data_SrcNet_LocalIP";
    static constexpr const char *Data_SrcPcd_FilePath = "Data_SrcPcap_FilePath"; // 从PCD

    static constexpr const char *Data_Callback_DecType = "Data_Callback_DecType";
    static constexpr const char *Data_Decode_SampleVoxel = "Data_Decode_SampleVoxel";
    static constexpr const char *Data_Decode_FiltMeanK = "Data_Decode_FiltMeanK";
    static constexpr const char *Data_Decode_FiltThreshold = "Data_Decode_FiltThreshold";
    static constexpr const char *Data_Decode_Transform = "Data_Decode_Transform";
    static constexpr const char *Data_Decode_CorrectionFile = "Data_Decode_CorrectionFile";

    static constexpr const char *Data_Callback_NoDelay = "Data_Callback_NoDelay";

    // Set Value
    void SetValue(std::string key, ConfValueType value);

    // Get Value
    ConfValueType GetValue(std::string key);
    ConfValueType GetDefaultValue(std::string key);

    bool addParameterChangedNotify(ParameterChangedNotify notify);

private:
    std::map<std::string, ConfValueType> _mapValues;
    std::map<std::string, ConfValueType> _mapDefaultValues;
    std::vector<ParameterChangedNotify> _paramterChangedNotify;
};